package com.gxar.file.server.db.service.strategy.impl;

import com.gxar.file.server.base.common.enums.TargetChannelEnum;
import com.gxar.file.server.base.common.enums.ProductEnum;
import com.gxar.file.server.base.model.upload.request.FilePartUploadRequest;
import com.gxar.file.server.base.model.upload.response.FilePartUploadResponse;
import com.gxar.file.server.base.sdk.NasHelper;
import com.gxar.file.server.db.service.strategy.TargetChannelStrategy;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;

/**
 * @author linsy
 * @version 1.0
 * @created 2023/7/13 13:44
 */
@Component
@RequiredArgsConstructor
public class NasTargetChannelStrategyImpl implements TargetChannelStrategy {

    private final NasHelper nasHelper;

    @Override
    public String getTargetChannel() {
        return TargetChannelEnum.NAS.getName();
    }

    @Override
    public Boolean uploadFile(ProductEnum productEnum, String fileName, InputStream streamFile, Boolean publicRead) {
        return nasHelper.uploadFile(productEnum, fileName, streamFile);
    }

    @Override
    public String downloadFile(ProductEnum productEnum, String fileKey, HttpServletResponse response) {
        return nasHelper.downloadFile(productEnum, fileKey, response);
    }

    @Override
    public String getFileUrl(ProductEnum product, String name) {
        return nasHelper.getFileUrl(product, name);
    }

    @Override
    public FilePartUploadResponse uploadPartFile(ProductEnum product, String name, FilePartUploadRequest request, MultipartFile file) {
        return null;
    }

    @Override
    public void deleteFile(String productName, String fileName) {
        // todo
    }

}
